//
//  UIScreen+XBAdd.m
//  XBCategoriesDemo
//
//  Created by kevin007 on 2021/4/12.
//

#import "UIScreen+XBAdd.h"

@implementation UIScreen (XBAdd)
+ (CGFloat)width {
    return self.size.width;
}

+ (CGFloat)height {
    return self.size.height;
}

+ (CGSize)size {
    return UIScreen.mainScreen.bounds.size;
}

+ (CGFloat)statusBarHeight {
    return CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
}

+ (CGFloat)navigationBarHeight {
    return [self statusBarHeight] + 44.0;
}

+ (CGFloat)tabbarHeight {
    return [self bottomSafeAreaHeight] + 49.0;
}

+ (CGFloat)topSafeAreaHeight {
    UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
    if (@available(iOS 11.0, *)) {
        return window.safeAreaInsets.top;
    }
    return 0.0;
}

+ (CGFloat)bottomSafeAreaHeight {
    UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
    if (@available(iOS 11.0, *)) {
        return window.safeAreaInsets.bottom;
    }
    return 0.0;
}

+ (BOOL)isiPhoneXSeries {
    return [self bottomSafeAreaHeight] > 0;
}

+ (CGFloat)scaleRate {
    return [self width]/375.0;
}
@end
